package fucai.com.fucai.Analyse;

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

import fucai.com.fucai.db.FuCaiNumber;

/**
 * @说 明： 这是个历史数据分析得出规律  我打算使用以前的东西这样我就 主要是还没看懂以前的是怎么一回事
 * @项目名称：fucai
 * @包 名： fucai.com.fucai.db
 * @类 名： Fucai
 * @创 建人： chenshuangniu
 * @创建时间：2015/12/13 8:53
 * @版 本：v1.0
 * @修 改人：
 * @修改时间：
 * @修改备注：
 */
public class HostoryDataAnanlyse {
    private String[][] openup;
    private String[][] open;
    private String[][] testup;
    private String[][] test;
    public List<FuCaiNumber> fList;

    public HostoryDataAnanlyse(List<FuCaiNumber> fList) {
        this.fList = fList;
    }

    public void getHistoryData() {
        open = new String[fList.size()][3]; // 从第二开始记录
        openup = new String[fList.size()][3]; // 从第二开始记录
        test = new String[fList.size()][3];
        testup = new String[fList.size()][3];
        for (int i = 0; i < fList.size(); i++) {
            FuCaiNumber fucaiNumber = new FuCaiNumber();
            fucaiNumber = fList.get(i);
            if (i > 0) {
                open[i - 1][0] = String.valueOf(fucaiNumber.getOpenBaiWei());
                open[i - 1][1] = String.valueOf(fucaiNumber.getOpenShiwei());
                open[i - 1][2] = String.valueOf(fucaiNumber.getOpenGewei());

                test[i - 1][0] = String.valueOf(fucaiNumber.getTestBaiWei());
                test[i - 1][1] = String.valueOf(fucaiNumber.getTestShiwei());
                test[i - 1][2] = String.valueOf(fucaiNumber.getTestGewei());
            }
            if (i < fList.size() - 1) {
                openup[i][0] = String.valueOf(fucaiNumber.getOpenBaiWei());
                openup[i][1] = String.valueOf(fucaiNumber.getOpenShiwei());
                openup[i][2] = String.valueOf(fucaiNumber.getOpenGewei());

                testup[i][0] = String.valueOf(fucaiNumber.getTestBaiWei());
                testup[i][1] = String.valueOf(fucaiNumber.getTestShiwei());
                testup[i][2] = String.valueOf(fucaiNumber.getTestGewei());
            }
        }

        culTsetOpen();
        culTestupOpen();
        culOpenupOpen();
    }

    /*
     利用上一期的试机号去统计下一期的开奖号；
     */
    public int[][] culTestupOpen() {
        col = 0;
        row = 0;
        while (true) {
            if (row == 3) change = -1;
            else change = Integer.valueOf(testup[col][row]).intValue();//数组的字符转化为整形
            if (row == 0) zero = change;
            if (row == 1) {
                first = change;
                if (first == zero) change = -1;
            }
            if (row == 2)
                if (change == zero || change == first) change = -1;    //判断text中的重复的 重复的的只执行2次
            switch (change) {
                case 0:
                    sard(0, col);
                    break;
                case 1:
                    sard(1, col);
                    break;
                case 2:
                    sard(2, col);
                    break;
                case 3:
                    sard(3, col);
                    break;
                case 4:
                    sard(4, col);
                    break;
                case 5:
                    sard(5, col);
                    break;
                case 6:
                    sard(6, col);
                    break;
                case 7:
                    sard(7, col);
                    break;
                case 8:
                    sard(8, col);
                    break;
                case 9:
                    sard(9, col);
                    break;
            }
            if (row < 3) row++;
            else {
                if (row == 3) row--;
                if (testup[++col][row] != null) row = 0;//换到下一行处理  列置0； 行加1；
                else break;
            }
        }
        return cuTestup;
    }

    public void sard(int counts, int col)                      //如果开奖号有值泽加一操作
    {
        cuTestup[counts][Integer.valueOf(open[col][0]).intValue()]++;
        if ((open[col][1]).equals(open[col][0])) {
        } else cuTestup[counts][Integer.valueOf(open[col][1]).intValue()]++;
        if ((open[col][0].equals(open[col][2])) || (open[col][2].equals(open[col][1]))) {
        } else
            cuTestup[counts][Integer.valueOf(open[col][2]).intValue()]++;  //开奖号重复的不计数   注意字符的相等  equals   和  == 的区别
    }

    /*
      利用上一期的开奖号统计下一期的开奖号
     */
    public int[][] culTsetOpen() {
        col = 0;
        row = 0;
        while (true) {
            if (row == 3) change = -1;
            else change = Integer.valueOf(test[col][row]).intValue();//数组的字符转化为整形
            if (row == 0) zero = change;
            if (row == 1) {
                first = change;
                if (first == zero) change = -1;
            }
            if (row == 2)
                if (change == zero || change == first) change = -1;    //判断text中的重复的 重复的的只执行2次
            switch (change) {
                case 0:
                    sard1(0, col);
                    break;
                case 1:
                    sard1(1, col);
                    break;
                case 2:
                    sard1(2, col);
                    break;
                case 3:
                    sard1(3, col);
                    break;
                case 4:
                    sard1(4, col);
                    break;
                case 5:
                    sard1(5, col);
                    break;
                case 6:
                    sard1(6, col);
                    break;
                case 7:
                    sard1(7, col);
                    break;
                case 8:
                    sard1(8, col);
                    break;
                case 9:
                    sard1(9, col);
                    break;
            }
            if (row < 3) row++;
            else {
                if (row == 3) row--;
                if (test[++col][row] != null) row = 0;//换到下一行处理  列置0； 行加1；
                else break;
            }
        }
        return cuTest;
    }

    public void sard1(int counts, int col)                      //如果开奖号有值泽加一操作
    {
        cuTest[counts][Integer.valueOf(open[col][0]).intValue()]++;
        if ((open[col][1]).equals(open[col][0])) {
        } else cuTest[counts][Integer.valueOf(open[col][1]).intValue()]++;
        if ((open[col][0].equals(open[col][2])) || (open[col][2].equals(open[col][1]))) {
        } else
            cuTest[counts][Integer.valueOf(open[col][2]).intValue()]++;  //开奖号重复的不计数   注意字符的相等  equals   和  == 的区别
    }

    public int[][] culOpenupOpen() {
        col = 0;
        row = 0;
        while (true) {
            if (row == 3) change = -1;
            else change = Integer.valueOf(openup[col][row]).intValue();//数组的字符转化为整形
            if (row == 0) zero = change;
            if (row == 1) {
                first = change;
                if (first == zero) change = -1;
            }
            if (row == 2)
                if (change == zero || change == first) change = -1;    //判断text中的重复的 重复的的只执行2次
            switch (change) {
                case 0:
                    sard2(0, col);
                    break;
                case 1:
                    sard2(1, col);
                    break;
                case 2:
                    sard2(2, col);
                    break;
                case 3:
                    sard2(3, col);
                    break;
                case 4:
                    sard2(4, col);
                    break;
                case 5:
                    sard2(5, col);
                    break;
                case 6:
                    sard2(6, col);
                    break;
                case 7:
                    sard2(7, col);
                    break;
                case 8:
                    sard2(8, col);
                    break;
                case 9:
                    sard2(9, col);
                    break;
            }
            if (row < 3) row++;
            else {
                if (row == 3) row--;
                if (openup[++col][row] != null) row = 0;//换到下一行处理  列置0； 行加1；
                else break;
            }
        }
        return cuOpenup;
    }

    public void sard2(int counts, int col)                      //如果开奖号有值泽加一操作
    {
        cuOpenup[counts][Integer.valueOf(open[col][0]).intValue()]++;
        if ((open[col][1]).equals(open[col][0])) {
        } else cuOpenup[counts][Integer.valueOf(open[col][1]).intValue()]++;
        if ((open[col][0].equals(open[col][2])) || (open[col][2].equals(open[col][1]))) {
        } else
            cuOpenup[counts][Integer.valueOf(open[col][2]).intValue()]++;  //开奖号重复的不计数   注意字符的相等  equals   和  == 的区别
    }

    public int[][] getCuOpenup() {
        return cuOpenup;
    }

    public int[][] getCuTest() {
        return cuTest;
    }

    public int[][] getCuTestup() {
        return cuTestup;
    }

    int col = 0, row = 0;
    int zero;
    int first;
    int change;
    int[][] cuOpenup = new int[10][10];
    int[][] cuTest = new int[10][10];
    int[][] cuTestup = new int[10][10];
}
